package com.elicitor.core;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Hello world!
 *
 */
public class App {

    public static void main(String[] args) {
       
        List <Double> OriginalMinimumSoundPressure = new ArrayList<Double>(); 
        List <Double> OriginalMaximumSoundPressure = new ArrayList<Double>(); 
        List <Double> OriginalMean = new ArrayList<Double>(); 
        List <Double> OriginalRootMeanSquare = new ArrayList<Double>(); 
        List <Double> OriginalStandardDeviation = new ArrayList<Double>(); 
        List <Double> OriginalEnergy = new ArrayList<Double>(); 
        List <Double> OriginalPower = new ArrayList<Double>(); 
        List <Double> OriginalEnergyinAir = new ArrayList<Double>(); 
        List <Double> OriginalPowerinAir = new ArrayList<Double>(); 
        List <Double> OriginalIntensity = new ArrayList<Double>(); 
        List <Double> Minimumpitch = new ArrayList<Double>(); 
        List <Double> Maximumpitch = new ArrayList<Double>(); 
        List <Double> pitchQ1 = new ArrayList<Double>(); 
        List <Double> pitchQ2 = new ArrayList<Double>(); 
        List <Double> pitchQ3 = new ArrayList<Double>(); 
        List <Double> pitchMean = new ArrayList<Double>(); 
        List <Double> pitchStandardDeviation = new ArrayList<Double>(); 
        
        
        
        
        
        
       
        Scanner scanner = null;
        Map <String, Object> femaleAnger= new HashMap<String, Object>();
        
        File file = new File("resources/maleSadness.txt");
 
        try {
 
             scanner = new Scanner(file);
 
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine();
                String result[] = line.split(",");
                System.out.println(line);
                System.out.println(result[0]);
        if(result.length == 17){            
        OriginalMinimumSoundPressure.add(Double.parseDouble(result[0]));
        OriginalMaximumSoundPressure.add(Double.parseDouble(result[1]));
        OriginalMean.add(Double.parseDouble(result[2]));
        OriginalRootMeanSquare.add(Double.parseDouble(result[3]));
        OriginalStandardDeviation.add(Double.parseDouble(result[4]));
        OriginalEnergy.add(Double.parseDouble(result[5]));
        OriginalPower.add(Double.parseDouble(result[6]));
        OriginalEnergyinAir.add(Double.parseDouble(result[7]));
        OriginalPowerinAir.add(Double.parseDouble(result[8]));
        OriginalIntensity.add(Double.parseDouble(result[9]));
        Minimumpitch.add(Double.parseDouble(result[10]));
        Maximumpitch.add(Double.parseDouble(result[11]));
        pitchQ1.add(Double.parseDouble(result[12]));
        pitchQ2.add(Double.parseDouble(result[13]));
        pitchQ3.add(Double.parseDouble(result[14]));
        pitchMean.add(Double.parseDouble(result[15]));
        pitchStandardDeviation.add(Double.parseDouble(result[16]));
        }
            }
        
        calcCentroid(OriginalMinimumSoundPressure, "OriginalMinimumSoundPressure");
        calcCentroid(OriginalMaximumSoundPressure, "OriginalMaximumSoundPressure");
        calcCentroid(OriginalMean, "OriginalMean");
        calcCentroid(OriginalRootMeanSquare, "OriginalRootMeanSquare");
        calcCentroid(OriginalStandardDeviation, "OriginalStandardDeviation");
        calcCentroid(OriginalEnergy, "OriginalEnergy");
        calcCentroid(OriginalPower, "OriginalPower");
        calcCentroid(OriginalEnergyinAir, "OriginalEnergyinAir");    
        calcCentroid(OriginalPowerinAir, "OriginalPowerinAir");
        calcCentroid(OriginalIntensity, "OriginalIntensity");    
        calcCentroid(Minimumpitch, "Minimumpitch");
        calcCentroid(Maximumpitch, "Maximumpitch");
        calcCentroid(pitchQ1, "pitchQ1");
        calcCentroid(pitchQ2, "pitchQ2");
        calcCentroid(pitchQ3, "pitchQ3");
        calcCentroid(pitchMean, "pitchMean");
        calcCentroid(pitchStandardDeviation, "pitchStandardDeviation");
        
        
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        finally{
            scanner.close();
        }
        
        
    }
    
    static void calcCentroid(List<Double> list, String attribute){
        
        double x =0;
        
        for (Double dd : list){
            x = x+dd;
        }
        System.out.println(attribute +"Centroid is "+(x/154));
    }
    
}
